/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the FOO module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/

function Component()
{
	installer.installationFinished.connect(this, Component.prototype.installationFinished1);
}

Component.prototype.installationFinished1 = function()
{
/*
	try
	{
		var isRoot = installer.gainAdminRights();//sudo must
		installer.execute("@TargetDir@/install/install.sh");
		//console.log(" --- shell " + ret);
	}
	catch(e)
	{
		console.log("Error Install : "  + e);
	}

	console.log(" *** installationFinished1");
*/
}

/*
var result = QMessageBox.question("quit.question", "Installer", "installationFinished1",
                QMessageBox.Yes | QMessageBox.No);

console.log(" --- installationFinished1 "  + result);
*/


Component.prototype.createOperations = function()
{
    component.createOperations();
	
    if (installer.value("os") == "win") { 
        try {
            var userProfile = installer.environmentVariable("USERPROFILE");
            installer.setValue("UserProfile", userProfile);
            component.addOperation("CreateShortcut", "@TargetDir@\\bin\\CommMaster.exe", "@UserProfile@\\Desktop\\CommMaster.lnk");
        } catch (e) {
            // Do nothing if key doesn't exist
        }
    }
/*
	//var isRoot = installer.gainAdminRights();

	try
	{
		//动态修改*.desktop中的Exec
		// sed -i "/^Exec=/cExec=/opt/a.sh" a.txt
		var args = ["/bin/bash","@TargetDir@/res/updateDesktop.sh"];
		var ret = component.addElevatedOperation("Execute",args);
		console.log(" --- shell " + ret);
	}
	catch(e)
	{
		console.log("Error Install : "  + e);
	}
*/
}


Component.prototype.isDefault = function()
{
    // select the component by default
    return true;
}

